package cn;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileTest {

    public static void main(String[] args) throws Exception{
        long time1=System.nanoTime();
        FileInputStream fis = new FileInputStream("1.pdf");
        FileOutputStream fos = new FileOutputStream("2.pdf");

        BufferedInputStream bis=new BufferedInputStream(fis);
        //使用装饰模式，把fis装饰进去bis中。使用缓冲读取速度变快
        BufferedOutputStream bos=new BufferedOutputStream(fos);

        int b;
        while((b=bis.read())!=-1){
            bos.write(b);
        }
        bis.close();
        bos.close();
        long time2=System.nanoTime();
        System.out.printf("运行时间为%d纳秒",(time2-time1));
    }
}
